<?php
include_once 'classes/controls/Form.php';
include_once 'classes/controls/TextBox.php';
include_once 'classes/controls/PasswordBox.php';
include_once 'classes/controls/SubmitButton.php';
include_once 'classes/controls/ImageButton.php';
include_once 'classes/Login.php';
include_once 'classes/controls/LogoutForm.php';
class LoginForm extends Form{
	private $username;
	private $passwordTextBox;
	function RunBeforeValidate(){
		$login = new Login();
		$login->Authenticate($this->Values['UserName'],$this->Values['Password']);
	}
	function CustomValidate() {
		if(strlen($this->Values['UserName'])<=0)
		$this->ErrorMessages['UserName']='Please give a username';
		if(strlen($this->Values['Password'])<=0)
		$this->ErrorMessages['Password']='Please give a password';
		$login = new Login();
		if(!$login->isAuthenticated())
		$this->ErrorMessages['NotMatch']='Username and password has not matched';
	}
	function NextWizardPage() {
		echo "Welcome";
		header ("Location:".$this->Wizard);
		//Sayfa yönlendirmesi yapılabilir.
	}
	function StoreData() {
		
	}
	function DisplayForm(){
		$login = new Login();
		if ($login->isAuthenticated()){
			$logout = new LogoutForm('Logout', 'index.php');
		}else{
			?>
<form action="<?php echo $_SERVER["SCRIPT_NAME"]?>" method="POST">
<div id="login-form-a">
<?php $this->SendErrorMessage('NotMatch')?>
    	      <div style="position:absolute;"><img alt="" src="images/uye_girisi_bg.png" style="_padding-top:600px;"></div>
    	      <div style="position:relative;padding:20px 25px;">
      	      <div><img alt="" src="images/uye_girisi.png" style="_padding-top:600px;"></div>
      	      <div style="padding-bottom:2px;padding-top:12px;"><label for="eposta"><img alt="Eposta" src="images/eposta-adresi.png" style="_padding-top:60px;"></label></div>
      	      <table class="input-l"><tbody><tr><td><?php $usernameTextBox = new TextBox($this,'UserName','')?><?php $this->SendErrorMessage('UserName')?></td></tr></tbody></table>
      	      <div style="padding-top:6px"><label for="sifre"><img alt="Şifre" src="images/sifre.png" style="_padding-top:60px;"></label></div>
      	      <table class="input-l"><tbody><tr><td><?php $passwordTextBox = new PasswordBox($this,'Password','')?><?php $this->SendErrorMessage('Password')?></td></tr></tbody></table>
      	      <table style="margin-top:5px;margin-left:-2px;width:179px;">
      	        <tbody><tr>
      	          <td align="left" valign="top"><div style="padding-top:2px;"><a id="sif-unuttum" href="http://www.google.com.tr/search?q=birbilenesor">Şifremi unuttum</a></div></td>
      	          <td style="text-align:right;padding-top:0px;"><?php $this->Additional();new ImageButton($this,'Login','images/giris.png','','');?></td>
      	        </tr>
              </tbody></table>
            </div>
          </div>
</form>
<?php
		}
	}
}

?>